<template>
  <div>
    <button @click="getCountRef">获取Count组件上的ref</button>
    <Count ref="CountRef"/>
    <hr>
    <MyHeader/>
  </div>
</template>

<script>
import Count from "./components/Count";
import MyHeader from "./components/MyHeader";
export default {
  name: "App",
  components: {
    Count,
    MyHeader
  },
  methods:{
    getCountRef(){
      /* 
        如果ref属性写在一个组件上,那么$refs对象上保存的是组件实例
      */
      console.log(this.$refs);
      console.log(this.$refs.CountRef);
    }
  }
};
</script>

<style scoped>
</style>